package com.sisgesbyte.dao.localizacion;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import com.sisgesbyte.data.entity.localizacion.PaisEntity;
import com.sisgesbyte.data.util.AbstractFacade;

@Stateless
public class LocalizacionPaisDaoImpl  extends AbstractFacade<PaisEntity> implements LocalizacionPaisDao{


	@PersistenceContext(unitName = "SigesSiscompPU")
	private EntityManager em;

	@Override
	protected EntityManager getEntityManager() {
		return em;
	}
	
	public LocalizacionPaisDaoImpl(){
		super(PaisEntity.class);
	}
	@Override
	public List<PaisEntity> listaPaises() {
		
		StringBuilder jpql = new StringBuilder();
		jpql.append("SELECT id, cod_continente, continente, cod_pais, nombre pais, cod_map, lat_map, ");
		jpql.append("lng_map, zoom_default, active ");
		jpql.append("FROM localizacion.pais ");
		jpql.append("order by nombre asc ");
		
		Query query = em.createNativeQuery(jpql.toString(),PaisEntity.class);
		
		List<PaisEntity> ls = query.getResultList();
		
		return ls;
	}

}
